import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: JSON.parse(localStorage.getItem('USER') || 'null'),
    sidebarCollapse: Boolean(localStorage.getItem('SIDEBARCOLLAPSE')) || false
  },
  mutations: {
    setUser (state, payload) {
      state.user = JSON.parse(payload)
      localStorage.setItem('USER', payload)
    },
    setSidebarCollapse (state, payload) {
      state.sidebarCollapse = payload
      localStorage.setItem('SIDEBARCOLLAPSE', payload.toString())
    }
  },
  actions: {
  },
  modules: {
  }
})
